<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改【请填写功能名称】')" />
    <th:block th:include="include :: summernote-css" />
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: jasny-bootstrap-css" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-experiment-edit">
        <input name="experimentId" th:field="${tbExperiment.experimentId}" id="experimentId" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">在线实验名称：</label>
            <div class="col-sm-8">
                <input name="experimentName" th:field="${tbExperiment.experimentName}" class="form-control" type="text" disabled="disabled">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">请选择教师指派：</label>
            <div class="col-sm-8">
                <!--<div hidden="true" id="messages" >
                    <select name="assignTeacher" class="form-control" id="assignTeacher" required>
                        <option th:each="user:${teacher}"  th:value="${user.userId}" th:text="${user.userName}"></option>
                    </select>
                </div>-->
                <div class="form-group">
                    <select class="form-control noselect2 selectpicker" data-none-selected-text="允许多选,再次点击取消选中：" multiple name="assignTeacher" id="assignTeacher">
                        <option th:each="user:${teacher}"  th:value="${user.userId}" th:text="${user.userName}"></option>
                        <option th:disabled="${teacher==null?true:false}"  th:text="无可添加教师" value="null" selected></option>
                    </select>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">已经指派给了：</label>
            <div class="col-sm-8">
                <div id="messages" >
                    <select name="assignTeacher" class="form-control" >
                        <option th:each="user1:${asignTeacher}"  th:value="${user1.userId}" th:text="${user1.userName}"></option>
                    </select>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: summernote-js" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: jasny-bootstrap-js" />
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: bootstrap-select-js" />
<script type="text/javascript">
    var prefix = ctx + "system/experiment";
    $("#form-experiment-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        console.log($("#assignTeacher").val())
        if ($.validate.form()) {
            $.ajax({
                url : prefix+'/addTeacher',
                data : {'experimentId':$("#experimentId").val(),'userIds':$("#assignTeacher").val()},
                type: 'post',
                dataType : 'json',
                success: function (data) {
                    if(data.code == 0){
                        $.modal.msgReload(data.msg,'success')
                    }else{
                        $.modal.msgReload(data.msg,'error')
                    }
                }
            })
            ///$.operate.save(prefix + "/edit", $('#form-experiment-edit').serialize());
        }
    }
</script>
</body>
</html>